<%@page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@include file="/common/session.jsp"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport"
	content="initial-scale=1.0, minimum-scale=1.0, maximum-scale=2.0, user-scalable=no, width=device-width">
<LINK type="text/css" rel="stylesheet" href="${ctx}/css/default.css" />
<script src="https://cdn.bootcss.com/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="${ctx}/js/xtable.js"></script>
<script type="text/javascript" src="${ctx}/dwr/engine.js"></script>
<script type="text/javascript" src="${ctx}/dwr/util.js"></script>
<script type='text/javascript'
	src='${ctx}/dwr/interface/FeedbackRpcService.js'></script>
<script type="text/javascript" src="${ctx}/js/loading.js"></script>
<title>用户反馈记录列表</title>
</head>
<body>

	<SCRIPT LANGUAGE="JavaScript">
		var feedbackThead = new Array(
				new XThead("反馈用户ID"), 
				new XThead("反馈用户姓名"), 
				new XThead("反馈用户电话"), 
				new XThead("反馈内容"),
				new XThead("反馈图片"), 
				new XThead("图片链接"), 
				new XThead("反馈时间"),
				new XThead("操作"));

		var feedbackXTable = new XTable("feedback", feedbackThead);

		feedbackXTable.XTbodyArray = function(model) {
			var array = new Array(
					new XTbody("feedback", model.userId, "string", null, null,
							"center"),
					new XTbody("feedback", model.user.userName, "string", null, null,
							"center"),
					new XTbody("feedback", model.user.userMobile, "string", null, null,
							"center"),
					new XTbody("feedback", model.feedbackContent, "string",
							null, null, "center"),
					new XTbody(
							"feedback",model.feedbackImage != null?"<img src='${fdfsPath}"+model.feedbackImage+".w_100xh_100' />":"无图片",
							"string", null, null, "center"), 
					new XTbody(
							"feedback",model.feedbackImage != null?"<a href='${fdfsPath}"+ model.feedbackImage + "'>查看大图</a>":"", "string", null,
							null, "center"), 
					new XTbody("feedback",
							model.feedbackCreateTime.Format("yyyy-MM-dd"),
							"string", null, null, "center"), 
							new XTbody(
							"feedback", "<a href='#' onclick=deleteFeedback('"
									+ model.feedbackId + "')>&nbsp;删除&nbsp;</a>",
							"string", null, null, "center")
				);
			return array;
		}

		feedbackXTable.getXList = function (page){
			var feedback = new Feedback();
			feedback.pageIndex = page;
			feedback.pageSize = feedbackXTable.pageSize;
			FeedbackRpcService.selectFeedbackList(feedback,
					function(list) {
						feedbackXTable.addTable(list);
					});
		    }
		    function getFeedbackPage() {
		    	var feedback = new Feedback();
		        FeedbackRpcService.selectFeedbackNum(feedback, function(num){feedbackXTable.setTotalPage(num);}) ;
		    }
	</SCRIPT>
</body>
</html>
<script>
	$(function(){
		getFeedbackPage();
	});

	 function deleteFeedback(feedbackId) {
		if (feedbackId == null || feedbackId == '') {
			return false;
		}

		if (confirm('确定要删除吗？')) {
			var feedback = new Feedback();
			feedback.feedbackId = feedbackId;
			FeedbackRpcService.deleteFeedback(feedback, callbackDeleteFeedback);
		} else {
			return false;
		}
	} 

	function callbackDeleteFeedback(data) {
		if (data) {
			alert('操作成功!');
			location.reload();
		}
	}
</script>
